//copy_cons.cpp
//will copy constructor augmented as constructor?
//No! Insert default constructor but not copy constructor.
#include <iostream>
using namespace std;

class Foo0
{
  //ISO C++ forbids in-class initialization of non-const static member 'i';
  static int i;
public:
  Foo0(void){  i++;cout<<"Foo0()"<<i<<endl; }
  Foo0(const Foo0&) { i++; cout<<"Foo0(const Foo0&)"<<i<<endl;}
};

int Foo0::i = 0;

class Bar
{
public:
  Bar(){ cout<<"Bar()"<<endl; }
  Bar(const Bar&) {cout<<"Bar(const Bar&)"<<endl; }
};

class FooBar:Foo0
{
  Bar bar;
public:
  FooBar(){ cout<<"FooBar()"<<endl;};
  FooBar(const FooBar& fb):Foo0(fb),bar(fb.bar) { 
    cout<<"FooBar(const FooBar&)"<<endl; 
  }
};
int main()
{
  FooBar fb0;

  cout<<"fb1(fb0)---------------"<<endl;
  FooBar fb1(fb0);

  cout<<"fb2 = fb0--------------"<<endl;
  FooBar fb2 = fb0;

  cout<<"fb3 = Foobar(fb0)------"<<endl;
  FooBar fb3 = FooBar(fb0);
  return 0;
}
